package com.tiancheng.trade.settlement.vo.settlement.admin.res;

import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @Auther: liudong
 * @Date: 2024/4/27 16:42
 * @Param ${tags}
 * @Description:
 */
@Data
public class PaymentOrderResVO {
    /**
     * 支付订单号
     */
    private String paymentId;

    /**
     * 渠道支付订单号
     */
    private String flowId;

    /**
     * 银行支付流水
     */
    private String payChannelOrderid;

    /**
     * 交易类型：订单类型：pay 支付，refund 退款
     */
    private String transactionType;
    private String transactionTypeCN;

    /**
     * 支付渠道
     */
    private String payChannel;
    private String payChannelCN;

    /**
     * 交易方式
     */
    private String payWay;
    private String payWayCN;

    /**
     * 交易金额
     */
    private Integer payAmount;
    /**
     * 订单金额
     */
    private Integer orderAmount;


    /**
     * 手续费
     */
    private Integer serviceCharge;

    /**
     * 结算金额
     */
    private Integer settlementAmount;

    /**
     * 通道费率
     */
    private BigDecimal rate;

    /**
     * 通道费=交易金额*通道费率
     */
    private BigDecimal payAmountRate;

    /**
     * 优惠金额
     */
    private Integer discount;

    /**
     * userId
     */
    private String uid;
    /**
     * 支付渠道用户标识
     */
    private String openid;

    /**
     * 支付订单数量
     */
    private Integer orderNum;
    /**
     * 交易时间
     */
    private LocalDateTime payTime;
    /**
     * 订单创建时间
     */
    private LocalDateTime createTime;

    /**
     * 通道费=交易金额*通道费率
     */
    public BigDecimal getPayAmountRate() {
        if (null != payAmount && null != rate) {
            BigDecimal bigNum = new BigDecimal("100");
            BigDecimal payBig = new BigDecimal(payAmount.toString());
            payAmountRate = payBig.multiply(rate).divide(bigNum);
        }
        return payAmountRate;
    }

}
